<template>
	<view class="zg-area">
		<view class="article">
			<rich-text :nodes="content"></rich-text>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex';
	
	export default {
		data() {
			return {
				content: '',
				id: '',
				type: '',
			}
		},
		computed:{
			...mapGetters(['getToken']),
		},
		onLoad(params) {
			console.log(params);
			this.id = parseInt(params.id)
			this.type = params.type
			if(!isNaN(this.id) && this.id > 0 && !isNaN(parseInt(this.type))) {
				this.getList1()
			} else {
				console.log('轮播图参数错误');
			}
		},
		methods:{
			// 轮播图
			getList1() {
				this.$http.post(this.$api.shop_index_6, {}, {
					params: {
						type: this.type
					}
				}).then(result => {
					if(result.code === 200) {
						const swipers = result.data;
						if(Array.isArray(swipers) && swipers.length > 0) {
							swipers.map(item => {
								if(item.id === this.id) {
									this.content = this.parseRichImgStyle(item.description)
								}
							})
						} else {
							this.content = ''
						}
					} else {
						this.content = ''
					}
				}).catch(() => {
					this.content = ''
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.article {
		padding: 30rpx;
	}
</style>
